package com.emode.action;

import java.io.File;
import java.util.Date;
import com.emode.entity.Bbstopic;
import com.opensymphony.xwork2.ActionContext;
import com.emode.base.BaseAction;;

public class TopicAtion extends BaseAction<Bbstopic>{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3681031719617602360L;
	private File[] file;
	private String[] fileFileName;
	
	//显示sid中的所有topic
	public String listAll(){
		p.init(topicservice.getCounts(section.getSid()));
		list = topicservice.findTopicWithPage(section.getSid(),p);
		System.out.println("---> page:"+p  +"----"+"row:"+p.getRows()+"getStartRow:"+p.getStartRow());
		ActionContext.getContext().getValueStack().push(list);
		return "topiclist";
		
	}
	//发表主贴
	public String addTopic(){
		if(model.getTcontents().toString().length()<7
				||model.getTtopic().toString().length()<7){
			msg = "内容不合法";
			return "topiclist";
		}
		model.setBbssection(section);
		model.setBbsusers(user);
		model.setTtime(new Date());
		topicservice.save(model);;
		sectionservice.updateTcount(section);
		section.setSid(section.getSid());
		return "totopic";		
	}
	//修改主贴
	//删除贴
	
	//模糊查询帖子
	public String searchTopic(){
		list = topicservice.findTitle(model.getTtopic());
		ActionContext.getContext().getValueStack().push(list);
		return "searchresult";
	}
	
	//导航 最新回复贴和最新发帖
	public String latesttopic(){
		p.init(topicservice.getCounts(null));
		list = topicservice.latestTopic(p);
		ActionContext.getContext().getValueStack().push(list);
		return "latesttopic";
	}
	
	
	
}
